<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
    <style>
        .fade-enter {
            opacity: 0;
        }

        .fade-enter-active {
            transition: opacity 3s;
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- transition包裹实现动画效果 -->
        <transition name='fade'>
            <div v-if='show'>helloworld</div>
        </transition>

        <!-- 希望显示与隐藏的时候有一个渐隐渐现的效果 -->
        <button @click="handleClick">切换</button>

    </div>

    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                show: true
            },
            methods: {
                handleClick: function () {
                    this.show = !this.show
                }
            },
        })
    </script>
</body>

</html>